import { Schema } from "mongoose";
import md5 from "md5";

const userSchema = new Schema({
  username: { type: String, required: true },
  password: {
    type: String,
    required: true,
    set: (value) => md5(value),
  },
  phone: { type: String, required: true },
  avatar: { type: String, default: null },
  // 关注数
  followCount: { type: Number, default: 0, min: 0 },
  // 粉丝数
  fansCount: { type: Number, default: 0, min: 0 },
  // 点赞数
  likeCount: { type: Number, default: 0, min: 0 },
  // 封面
  cover: { type: String, default: null },
  // 描述
  description: { type: String, default: null },
  createTime: { type: Date, default: Date.now },
  updateTime: { type: Date, default: Date.now },
});

export default userSchema;
